package com.example.child_protection.controller;

import com.example.child_protection.dto.base.BaseResponseDTO;
import com.example.child_protection.dto.request.SimpleIdRequestDTO;
import com.example.child_protection.dto.request.add.SystemDiseaseInsertRequestDTO;
import com.example.child_protection.dto.request.find.SystemDiseaseRequestDTO;
import com.example.child_protection.dto.request.update.SystemDiseaseContentUpdateRequestDTO;
import com.example.child_protection.dto.request.update.SystemDiseaseUpdateRequestDTO;
import com.example.child_protection.dto.response.SystemDiseaseListResponseDTO;
import com.example.child_protection.dto.response.SystemDiseaseResponseDTO;
import com.example.child_protection.service.SystemDiseaseManageService;
import com.example.child_protection.service.SystemDiseaseQueryService;
import com.example.child_protection.util.ContentType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 疾病管理控制层
 * @date 2018-11-2
 * @author Biz
 */
@RestController
@RequestMapping("systemDisease")
@Api(value = "/api-systemDisease", description = "疾病管理")
public class SystemDiseaseController extends BaseController {

    @Autowired
    public SystemDiseaseManageService systemDiseaseManageService;

    @Autowired
    public SystemDiseaseQueryService systemDiseaseQueryService;

    @ApiOperation(value ="查询疾病", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findId", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemDiseaseResponseDTO findId(SimpleIdRequestDTO requestDTO,HttpServletRequest request)throws Exception{
        SystemDiseaseResponseDTO responseDTO = systemDiseaseQueryService.findId(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="查询疾病列表信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findList", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemDiseaseListResponseDTO findList(SystemDiseaseRequestDTO requestDTO, HttpServletRequest request)throws Exception{
        SystemDiseaseListResponseDTO responseDTO = systemDiseaseQueryService.findList(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="添加疾病", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO insert(SystemDiseaseInsertRequestDTO requestDTO)throws Exception{
        requestDTO.setCreatePersonId(this.getLoginUserId());
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemDiseaseManageService.insert(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改疾病", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO update(SystemDiseaseUpdateRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemDiseaseManageService.update(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改疾病文本编辑器内容", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/updateContent", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO updateContent(SystemDiseaseContentUpdateRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemDiseaseManageService.updateContent(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="删除疾病", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO delete(SimpleIdRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemDiseaseManageService.delete(requestDTO);
        return responseDTO;
    }

}
